load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "ingest",
    srcs = [
        "backend.go",
        "backend_mgr.go",
        "checkpoint.go",
        "config.go",
        "disk_root.go",
        "engine.go",
        "engine_mgr.go",
        "env.go",
        "mem_root.go",
        "message.go",
        "mock.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/ddl/ingest",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/lightning/backend",
        "//br/pkg/lightning/backend/encode",
        "//br/pkg/lightning/backend/kv",
        "//br/pkg/lightning/backend/local",
        "//br/pkg/lightning/checkpoints",
        "//br/pkg/lightning/common",
        "//br/pkg/lightning/config",
        "//br/pkg/lightning/errormanager",
        "//br/pkg/lightning/log",
        "//pkg/config",
        "//pkg/ddl/internal/session",
        "//pkg/ddl/util",
        "//pkg/kv",
        "//pkg/meta",
        "//pkg/parser/mysql",
        "//pkg/sessionctx",
        "//pkg/sessionctx/variable",
        "//pkg/table",
        "//pkg/util",
        "//pkg/util/dbterror",
        "//pkg/util/generic",
        "//pkg/util/logutil",
        "//pkg/util/memory",
        "//pkg/util/size",
        "@com_github_google_uuid//:uuid",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_tikv_client_go_v2//util",
        "@com_github_tikv_pd_client//:client",
        "@io_etcd_go_etcd_client_v3//:client",
        "@io_etcd_go_etcd_client_v3//concurrency",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "ingest_test",
    timeout = "short",
    srcs = [
        "checkpoint_test.go",
        "env_test.go",
        "integration_test.go",
        "main_test.go",
        "mem_root_test.go",
    ],
    embed = [":ingest"],
    flaky = True,
    race = "on",
    shard_count = 16,
    deps = [
        "//pkg/config",
        "//pkg/ddl",
        "//pkg/ddl/ingest/testutil",
        "//pkg/ddl/internal/session",
        "//pkg/ddl/testutil",
        "//pkg/ddl/util/callback",
        "//pkg/domain",
        "//pkg/errno",
        "//pkg/parser/model",
        "//pkg/testkit",
        "//tests/realtikvtest",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
